package com.shop.common;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

@JsonInclude(JsonInclude.Include.ALWAYS)
public class ResponseResult<T> implements Serializable {
    private T data;
    private Meta meta;

    public ResponseResult(T data, Meta meta) {
        this.data = data;
        this.meta = meta;
    }

    public ResponseResult() {
        this.meta = new Meta();
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Meta getMeta() {
        return meta;
    }

    public void setMeta(Meta meta) {
        this.meta = meta;
    }

    //
    public void setSuccess(){
        meta.setStatus(ResponseCode.SUCCESS.getCode());
        meta.setMsg(ResponseCode.SUCCESS.getMessage());
    }

    public void setSuccess(String msg){
        meta.setStatus(ResponseCode.SUCCESS.getCode());
        meta.setMsg(msg);
    }
    public void setSuccess(String msg,T data){
        meta.setStatus(ResponseCode.SUCCESS.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setCREATED(){
        meta.setStatus(ResponseCode.CREATED.getCode());
        meta.setMsg(ResponseCode.CREATED.getMessage());
    }

    public void setCREATED(String msg){
        meta.setStatus(ResponseCode.CREATED.getCode());
        meta.setMsg(msg);
    }
    public void setCREATED(String msg,T data){
        meta.setStatus(ResponseCode.CREATED.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setBADREQUEST(){
        meta.setStatus(ResponseCode.BADREQUEST.getCode());
        meta.setMsg(ResponseCode.BADREQUEST.getMessage());
    }
    public void setBADREQUEST(String msg){
        meta.setStatus(ResponseCode.BADREQUEST.getCode());
        meta.setMsg(msg);
    }
    public void setBADREQUEST(String msg,T data){
        meta.setStatus(ResponseCode.BADREQUEST.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setDELETED(){
        meta.setStatus(ResponseCode.DELETED.getCode());
        meta.setMsg(ResponseCode.DELETED.getMessage());
    }
    public void setDELETED(String msg){
        meta.setStatus(ResponseCode.DELETED.getCode());
        meta.setMsg(msg);
    }
    public void setDELETED(String msg,T data){
        meta.setStatus(ResponseCode.DELETED.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setINTERNALSERVERERROR(){
        meta.setStatus(ResponseCode.INTERNALSERVERERROR.getCode());
        meta.setMsg(ResponseCode.INTERNALSERVERERROR.getMessage());
    }
    public void setINTERNALSERVERERROR(String msg){
        meta.setStatus(ResponseCode.INTERNALSERVERERROR.getCode());
        meta.setMsg(msg);
    }
    public void setINTERNALSERVERERROR(String msg,T data){
        meta.setStatus(ResponseCode.INTERNALSERVERERROR.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setUNAUTHORIZED(){
        meta.setStatus(ResponseCode.UNAUTHORIZED.getCode());
        meta.setMsg(ResponseCode.UNAUTHORIZED.getMessage());
    }
    public void setUNAUTHORIZED(String msg){
        meta.setStatus(ResponseCode.UNAUTHORIZED.getCode());
        meta.setMsg(msg);
    }
    public void setUNAUTHORIZED(String msg,T data){
        meta.setStatus(ResponseCode.UNAUTHORIZED.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setFORBIDDEN(){
        meta.setStatus(ResponseCode.FORBIDDEN.getCode());
        meta.setMsg(ResponseCode.FORBIDDEN.getMessage());
    }
    public void setFORBIDDEN(String msg){
        meta.setStatus(ResponseCode.FORBIDDEN.getCode());
        meta.setMsg(msg);
    }
    public void setFORBIDDEN(String msg,T data){
        meta.setStatus(ResponseCode.FORBIDDEN.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setNOTFOUND(){
        meta.setStatus(ResponseCode.NOTFOUND.getCode());
        meta.setMsg(ResponseCode.NOTFOUND.getMessage());
    }
    public void setNOTFOUND(String msg){
        meta.setStatus(ResponseCode.NOTFOUND.getCode());
        meta.setMsg(msg);
    }
    public void setNOTFOUND(String msg,T data){
        meta.setStatus(ResponseCode.NOTFOUND.getCode());
        meta.setMsg(msg);
        this.data = data;
    }
    public void setUnprocesableentity(){
        meta.setStatus(ResponseCode.Unprocesableentity.getCode());
        meta.setMsg(ResponseCode.Unprocesableentity.getMessage());
    }
    public void setUnprocesableentity(String msg){
        meta.setStatus(ResponseCode.Unprocesableentity.getCode());
        meta.setMsg(msg);
    }
    public void setUnprocesableentity(String msg,T data){
        meta.setStatus(ResponseCode.Unprocesableentity.getCode());
        meta.setMsg(msg);
        this.data = data;
    }

}

class Meta{
    private Integer status;
    private String msg;

    public Meta() {
    }

    public Meta(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
